package org.samith.web.servlet;

import java.io.IOException;
import java.util.Collection;

import javax.ejb.EJB;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.samith.dao.ServiceTypeDao;
import org.samith.entity.ServiceType;

@SuppressWarnings("serial")
public class ServicesIndexServlet extends HttpServlet {

	@EJB
	ServiceTypeDao serviceTypeDao;
	
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		ServletContext context = getServletConfig().getServletContext();
		Collection<ServiceType> services = serviceTypeDao.list();
		request.setAttribute("services", services);
		context.getRequestDispatcher("/Services/index.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
